home *** CD-ROM | disk | FTP | other *** search
- Path: trib.apple.com!usenet
- From: Amir <Amir@bayarea.net>
- Newsgroups: comp.lang.c++
- Subject: Re: Newbie question re getting local time
- Date: Fri, 05 Apr 1996 17:45:58 -0700
- Organization: Apple Computer, Inc., Cupertino, California
- Message-ID: <3165BEC6.13EE@bayarea.net>
- References: <3165427c.147901903@news.demon.co.uk>
- NNTP-Posting-Host: 17.128.203.152
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (Macintosh; I; PPC)
-
- I thought I replied this one, but it seems that the reply
- is lost, so forgive me if I submitted two replies.
-
- Martin McKean wrote:
- >
- > Can anyone tell me why the following won't work:
- >
- > int iDay;
- > LPSYSTEMTIME gLocalTime;
- > GetLocalTime(gLocalTime);
- > iDay=gLocalTime.wDay;
- >
- > As far as I can work out the SYSTEMTIME structure is included, and
- > contains the paramater wDay. The compile error I get is:
- >
- > error C2231: '._SYSTEMTIME::wDay' : left operand points to 'struct',
- > use '->'
- >
- > But if I change refs to gLocalTime.wDay to gLocalTime->wDay it
- > compiles, but when debugging it stops at the last line above saying
- > "Unhandled exception - Access violation".
- >
- > All I want is the day of the month; can anyone help?? (MSVC++4)
- >
- > Thanks,
- > Martin
-
- You don't write which system do you use, and how SYSTEMTIME,
- LPSYSTEMTIME and GetLocalTime, so I hope my assumptions are right,
- and if not prob. someone will correct me.
-
- SYSTEMTIME is by what you say the time struct, LPSYSTEMTIME
- is prob. defined as a pointer to that struct (LP - Long Pointer ?,
- sounds like a PC system :P )
-
- GetLocalTime probably accepts a pointer to the SYSTEMTIME
- struct, which you did passed to it, but your pointer doesn't
- point to any valid structure (you didn't allocate the memory)
-
- This will prob work:
-
-
- int iDay;
- SYSTEMTIME gLocalTime;
- ^^^^^^^^^^
- GetLocalTime( & gLocalTime);
- ^^^
- iDay=gLocalTime.wDay;
-
- Well I hope this helps
-
- Amir
-